<?php

	// TITLE: Home_owner_requirement_type AUTO MODEL
	// FILE: scaffolding/model/home_owner_requirement_type.php
	// AUTHOR: AUTOGEN
	// CREATED: 2015/04/20 07:49:57
	// DESCRIPTION: 
	// REQUIREMENTS: 

	$createHomeOwnerRequirementType = function($con, $homeOwnerRequirementType) {
		$sql = 'INSERT INTO home_owner_requirement_type (id, status_id, title, description) VALUES (';
		$sql .= $home_owner_requirement_type->getId() . ', ';
		$sql .= $home_owner_requirement_type->getStatusId() . ', ';
		$sql .= $home_owner_requirement_type->getTitle() . ', ';
		$sql .= $home_owner_requirement_type->getDescription() . ')';
		$sql .= ')';
		$result = mysqli_query($con, $sql);
		$id = ($result) ? mysqli_insert_id($con) : $result;
		mysqli_close($con);
		return $id;
	};

	$readHomeOwnerRequirementType = function($con, $id) {
		$sql = 'SELECT * FROM home_owner_requirement_type WHERE id = ' . $id;
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$result = mysqli_fetch_array($results);
			$homeOwnerRequirementType = new HomeOwnerRequirementType();
			$homeOwnerRequirementType->setId(result[0]);
			$homeOwnerRequirementType->setStatusId($dbio->select($readStatus(result[1])));
			$homeOwnerRequirementType->setTitle(result[2]);
			$homeOwnerRequirementType->setDescription(result[3]);
		} else {
			$homeOwnerRequirementType = false;
		}
		return $homeOwnerRequirementType;
	};

	$updateHomeOwnerRequirementType = function($con, $homeOwnerRequirementType) {
		$sql = 'UPDATE home_owner_requirement_type SET ';
		$sql .= 'id = ' . $home_owner_requirement_type->getId() . ', ';
		$sql .= 'status_id = ' . $home_owner_requirement_type->getStatusId() . ', ';
		$sql .= 'title = ' . $home_owner_requirement_type->getTitle() . ', ';
		$sql .= 'description = ' . $home_owner_requirement_type->getDescription() ;
		$sql .= 'WHERE id = ' . id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$deleteHomeOwnerRequirementType = function($con, $id) {
		$sql = 'DELETE FROM home_owner_requirement_type WHERE id = ' . $id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$listHomeOwnerRequirementType = function($con) {
		$sql = 'SELECT * FROM home_owner_requirement_type';
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$homeOwnerRequirementTypes = array();
			while ($result = mysqli_fetch_array($results)) {
				$homeOwnerRequirementType = new HomeOwnerRequirementType();
				$homeOwnerRequirementType->setId(result[0]);
				$homeOwnerRequirementType->setStatusId($dbio->select($readStatus(result[1])));
				$homeOwnerRequirementType->setTitle(result[2]);
				$homeOwnerRequirementType->setDescription(result[3]);
				$homeOwnerRequirementTypes[] = homeOwnerRequirementType;
			}// end while
		} else {
			$homeOwnerRequirementTypes = false;
		}
		return $homeOwnerRequirementTypes;
	};

